<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018\5\17 0017
 * Time: 18:20
 */

namespace App\Services;



use App\Models\Role;

class AdminService
{
    public static function adminRole($admin,$roles){
        $role_ids = $admin->roles->pluck('id');
        $new_role_ids = Role::find($roles)->pluck('id');

        $addIds = $new_role_ids->diff($role_ids);
        $delIds = $role_ids->diff($new_role_ids);

        $admin->roles()->attach($addIds);
        $admin->roles()->detach($delIds);
    }

}